<template>
  <div class="quote">
    <div class="quoteTop">
      <h4 class="var_bgColor">个人信息</h4>

      <div class="query">
        <Row>

          <Col span="6" v-if="dir.name != 3" class="input_info">
          <label>用户名</label>
          <Input size="small" style="width: 50%" v-model="info.name" :disabled="dir.name == 2"> </Input>
          </Col>

          <Col span="6" v-if="dir.mobile != 3" class="input_info">
          <label>手机号码</label>
          <Input size="small" style="width: 50%" v-model="info.mobile" :disabled="dir.mobile == 2"> </Input>
          </Col>

          <Col span="6" v-if="dir.insuredArea != 3" class="input_info">
          <label>投保区域</label>
          <Select size="small" v-model="info.insuredArea" style="width: 50%" :disabled="dir.insuredArea == 2">
            <Option v-for="(item, index) in insuredArea" v-bind:value="index" v-text="item"></Option>
          </Select>
          </Col>

          <Col span="6" v-if="dir.recommendMobile != 3" class="input_info">
          <label>推荐人手机号</label>
          <Input size="small" style="width: 50%" v-model="info.recommendMobile"
                 :disabled="dir.recommendMobile == 2"> </Input>
          </Col>

          <Col span="6" v-if="dir.recommendName != 3" class="input_info">
          <label>推荐人名称</label>
          <Input size="small" style="width: 50%" v-model="info.recommendName"
                 :disabled="dir.recommendName == 2"/>
          </Col>

          <Col span="6" v-if="dir.state != 3" class="input_info">
          <label>状态</label>
          <Select size="small" v-model="info.state" style="width: 50%" :disabled="dir.state == 2">
            <Option v-for="(item,index) in state" v-bind:value="item.code" v-text="item.name"></Option>
          </Select>
          </Col>

          <Col span="6" v-if="dir.password != 3" class="input_info">
          <label>密码</label>
          <Input size="small" style="width: 50%" v-model="info.password" :disabled="dir.password == 2"/>
          </Col>

          <Col span="6" v-if="dir.showCommission != 3" class="input_info">
          <label>是否显示佣金</label>
          <Select size="small" v-model="info.showCommission" style="width: 50%" :disabled="dir.showCommission == 2">
            <Option v-for="(item,index) in yesOrNo" v-bind:value="item.code" v-text="item.name"></Option>
          </Select>
          </Col>

          <Col span="6" class="input_info">
          <label>级别</label>
          <Select size="small" v-model="info.levelId" style="width: 50%">
            <Option v-for="(item,index) in levelInfo" v-bind:value="item.code" v-text="item.name"></Option>
          </Select>
          </Col>

          <Col span="6" class="input_info">
          <label>允许登陆网页</label>
          <Select size="small" v-model="info.loginPcFlag" style="width: 50%">
            <Option v-for="(item,index) in yesOrNo" v-bind:value="item.code" v-text="item.name"></Option>
          </Select>
          </Col>

        </Row>

      </div>
    </div>
  </div>
</template>

<script>
  import api from '../../../utils/api.js'
  import {queryROLE, queryPartnerId, queryPartnerName} from '../../../utils/common.js';
  import reqDic from '../../../utils/requestDictionary.js';

  export default{
    props: {
      info: {
        type: Object,
      },
      insuredArea: {
        type: Object,
      },
      state: {
        type: Object,
      },
      id: {
        type: String,
      }
    },
    data: function () {
      return {
        dir: {
          'name': '3',
          'mobile': '3',
          'insuredArea': '3',
          'recommendMobile': '3',
          'recommendName': '3',
          'state': '3',
        },
        myRole: '',
        yesOrNo: reqDic.QueryDictionary("YESORNO"),
        levelInfo: reqDic.QueryDictionary("PARTNERSTARLEVEL"),
      }
    },
    methods: {},
    created: function () {
      this.myRole = queryROLE();

      /**
       * 1:显示可编辑
       * 2:显示不可编辑
       * 3:不显示
       */

      if (this.myRole == 1) {
        if (this.id === '-1') {
          this.dir = {
            'name': '1',
            'mobile': '1',
            'insuredArea': '1',
            'recommendMobile': '1',
            'recommendName': '3',
            'state': '1',
            'password': '1',
            'showCommission': '1',
          }
        } else {
          this.dir = {
            'name': '1',
            'mobile': '1',
            'insuredArea': '1',
            'recommendMobile': '2',
            'recommendName': '2',
            'state': '1',
            'password': '3',
            'showCommission': '1'
          }
        }
      } else if (this.myRole == 2) {
        this.dir = {
          'name': '1',
          'mobile': '2',
          'insuredArea': '1',
          'recommendMobile': '2',
          'recommendName': '2',
          'state': '2',
          'password': '3',
          'showCommission': '1'
        }
      } else if (this.myRole == 3) {
        this.dir = {
          'name': '1',
          'mobile': '2',
          'insuredArea': '1',
          'recommendMobile': '2',
          'recommendName': '2',
          'state': '2',
          'password': '3',
          'showCommission': '1'
        }
      }
    }
  }

</script>

